package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description AlertDataController
 * @Author zhengyuan&junjun
 * @Date 2024-11-04
 */
@RestController
@RequestMapping("/alert-data")
@ApiOperation("报警数据相关接口")
public class AlertDataController{
   @Autowired
    private  AlertDataService alertDataService;

  /****
    @GetMapping("/pageQuery")
    @ApiOperation("分页查询报警数据")
    public ResponseResult<PageResponse<AlertDataVo>> page (
            @ApiParam(value = "页码",required = true) @RequestParam("pageNum") Integer pageNum,
            @ApiParam(value = "页面大小",required = true) @RequestParam("pageSize") Integer pageSize,
            @ApiParam(value = "设备名称") @RequestParam(value = "deviceName",required = false) String deviceName,
            @ApiParam(value = "结束报警时间") @RequestParam(value = "endTime",required = false) Long endTime,
            @ApiParam(value = "报警数据id") @RequestParam(value = "id",required = false) Integer id,
            @ApiParam(value = "开始报警时间") @RequestParam(value = "startTime",required = false) Long startTime,
            @ApiParam(value = "状态,0:待处理,1:已处理") @RequestParam(value = "status",required = false) Integer status ){
     PageResponse<AlertDataVo> pageResponse = alertDataService.getDataPage(pageNum,pageSize,deviceName,endTime,id,startTime,status);

     return ResponseResult.success(pageResponse);



    }
****/

 /***

   @GetMapping("/pageQuery")
   @ApiOperation("分页查询报警数据")
   public  ResponseResult<PageResponse<AlertDataVo>> page(AlertDataPageQueryDto alertDataPageQueryDto){
    PageResponse<AlertDataVo> pageResponse = alertDataService.getpage(alertDataPageQueryDto);
    return  ResponseResult.success(pageResponse);
   }
***/
/***
  @GetMapping("/pageQuery")
  @ApiOperation("分页查询报警数据")
  public  ResponseResult<PageResponse<AlertDataVo>> page(AlertDataPageQueryDto alertDataPageQueryDto){
      PageResponse<AlertDataVo> pageResponse = alertDataService.getpage(alertDataPageQueryDto);
      return  ResponseResult.success(pageResponse);


  }
/***

@GetMapping("/pageQuery")
@ApiOperation("分页查询报警数据")
public ResponseResult<PageResponse<AlertDataVo>> page (
        @ApiParam(value = "页码",required = true) @RequestParam("pageNum") Integer pageNum,
        @ApiParam(value = "页面大小",required = true) @RequestParam("pageSize") Integer pageSize,
        @ApiParam(value = "设备名称") @RequestParam(value = "deviceName",required = false) String deviceName,
        @ApiParam(value = "结束报警时间") @RequestParam(value = "endTime",required = false) Long endTime,
        @ApiParam(value = "报警数据id") @RequestParam(value = "id",required = false) Integer id,
        @ApiParam(value = "开始报警时间") @RequestParam(value = "startTime",required = false) Long startTime,
        @ApiParam(value = "状态,0:待处理,1:已处理") @RequestParam(value = "status",required = false) Integer status ) {
    PageResponse<AlertDataVo> pageResponse = alertDataService.getDataPage(pageNum, pageSize, deviceName, endTime, id, startTime, status);

    return ResponseResult.success(pageResponse);
}
***/
 /***
 @GetMapping("/pageQuery")
 @ApiOperation(value = "分页查询报警数据")
 public ResponseResult<PageResponse<AlertDataVo>> pageQuery(AlertDataPageQueryDto alertDataPageQueryDto) {
     return ResponseResult.success(alertDataService.adminPageQuery(alertDataPageQueryDto));
 }
 ***/
 @GetMapping("/pageQuery")
 @ApiOperation("分页查询报警数据")
 public ResponseResult<PageResponse<AlertDataVo>> page (
         @ApiParam(value = "页码",required = true) @RequestParam("pageNum") Integer pageNum,
         @ApiParam(value = "页面大小",required = true) @RequestParam("pageSize") Integer pageSize,
         @ApiParam(value = "设备名称") @RequestParam(value = "deviceName",required = false) String deviceName,
         @ApiParam(value = "结束报警时间") @RequestParam(value = "endTime",required = false) Long endTime,
         @ApiParam(value = "报警数据id") @RequestParam(value = "id",required = false) Integer id,
         @ApiParam(value = "开始报警时间") @RequestParam(value = "startTime",required = false) Long startTime,
         @ApiParam(value = "状态,0:待处理,1:已处理") @RequestParam(value = "status",required = false) Integer status ) {
     PageResponse<AlertDataVo> pageResponse = alertDataService.getDataPage(pageNum, pageSize, deviceName, endTime, id, startTime, status);

     return ResponseResult.success(pageResponse);
   }
    @PutMapping("/handleAlertData/{id}")
    @ApiOperation("处理设备报警数据")
    public ResponseResult<Void> handleAlertData(@ApiParam(value = "报警数据ID", required = true) @PathVariable("id") Long id,
                                                @RequestBody AlertDataHandleDto alertDataHandleDto) {

         alertDataService.handleAlertData(id,alertDataHandleDto);


        return ResponseResult.success();
    }


}



